import { GameParams } from '../../Basic/Config/DataConfig';
import { DataMgr } from '../../Basic/Manager/DataManager';
import { EventManager } from '../../Basic/Manager/EventManager';
import { PanelModel } from '../../Basic/UI/PanelModel';
import { EventType } from '../Config/GameEnum';

export class EnergyModel extends PanelModel {
  className: string = 'EnergyModel';
  loadRes: string = 'maingame/dialog/EnergyPanel';

  /** 增加体力 */
  addEnergy(count: number) {
    DataMgr.gameParams.set(GameParams.energy, DataMgr.gameParams.get(GameParams.energy) + count);
    DataMgr.SaveData('GameParams');
    // GameManager.I.player.addPlayParam(PlayerParam.PHYSICS, count);
    EventManager.Ins().emit(EventType.REFRESH_ENERGY);
  }

  /** 消耗体力 */
  useEnergy(count: number) {
    DataMgr.gameParams.set(GameParams.energy, DataMgr.gameParams.get(GameParams.energy) - count);
    DataMgr.SaveData('GameParams');
    EventManager.Ins().emit(EventType.REFRESH_ENERGY);
  }
}
